package com.woniu.utils;

import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONUtil;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;
@Component
public class SMSUtil {


    public static String sendCode(String mobile, String code) {

        String apiUrl = "https://106.ihuyi.com/webservice/sms.php?method=Submit";
        String content = " 您的验证码是：" + code + "。请不要把验证码泄露给其他人。";
        Map<String, Object> params = new HashMap<String, Object>();

        params.put("account","C05482075");
        params.put("password","8f185503265c400b7da6b134bbce632d");
        params.put("mobile",mobile);
        params.put("content", content);
        params.put("format", "json");

        HttpResponse response = HttpRequest.post(apiUrl).form(params).execute();
        String result = JSONUtil.parseObj(response.body()).get("code").toString();
        return result;
    }
}
